import java.util.InputMismatchException;
import java.util.Scanner;

public class Test2 {
    public static void func(int[] array) throws NullPointerException,ArrayIndexOutOfBoundsException {
        if (array == null) {
            throw new NullPointerException("空指针异常...");
        }
        System.out.println("array != null");
    }
    public static void getData() {
        try {
            Scanner scanner = new Scanner(System.in);
            int a = scanner.nextInt();
            System.out.println(a);
        } catch(InputMismatchException e) {
            e.printStackTrace();
            System.out.println("输入不匹配...");
        } finally {
            System.out.println("finally继续执行...");
        }
    }

    public static void main(String[] args) {
        getData();
    }
        public static void main1(String[] args) {
        try {
            int[] array = {1,2,3,4,5};
            //int[] array = null;
            //System.out.println(array[6]);
            func(array);
        } catch(ArrayIndexOutOfBoundsException e){
            e.printStackTrace();
            System.out.println("数组越界异常...");
            } catch (NullPointerException e){
            e.printStackTrace();
            System.out.println("空指针异常...");
            } finally{
            System.out.println("程序继续执行...");
            }
    }
}
